package vn.com.fsoft.oopai.fsi.rule;

import vn.com.fsoft.oopai.fsi.common.Common;
import vn.com.fsoft.oopai.fsi.game.GameState;

/**
 * Class ThirdLevelRules.
 * The information about the third level rules.
 * @author OOPAI Group
 *
 */
public class ThirdLevelRules extends SecondLevelRules {

	@Override
	public boolean checkWin(GameState gameState) {
		if(gameState.getTotalViableSpaceClicked() >= Common.NUMBER_CLICK_TO_WIN || 
				gameState.getTotalToolBreakerFlagged() >= gameState.getInitializeNumOfFlag())
			return true;
		return false;
	}
	
	@Override
	public boolean isAbleToFlag() {
		return true;
	}
	
	/**
	 * This method determine the number of click in each cell can increase or not
	 * Level 3 does not allow duplicate click on each cell
	 * So that if a cell has not clicked yet, it can be clicked one time.
	 */
	@Override
	public boolean isNumClickAbleToAdd(GameState gameState, int x, int y) {
		// Cell is not clicked yet and not flagged yet 
		if(gameState.getNumClick(x, y)==0 && !gameState.isFalgged(x, y))
			return true;
		return false;
	}

	@Override
	public boolean isAbleToMultipleFlag() {
		return true;
	}
}
